package com.interview.item.javabase.codeDemo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Scanner;

/**
 * @Author:zxh
 * @Description: 冒泡排序演示
 * @Date: 2020/3/24
 * @Modified By:
 */
public class Bubbling {
    private static Logger logger = LoggerFactory.getLogger(Bubbling.class);

    static void bubbliing() {
        Scanner scanner = new Scanner(System.in);
        int[] ints = {7,3,5,8,9,1,2};//new int[7];
        int temp;
        /*for (int i = 0; i < ints.length; i++) {
            ints[i] = scanner.nextInt();
        }*/

        for (int i = 0; i < ints.length - 1; i++) {
            for (int j = 0; j < ints.length - i - 1; j++) {
                if (ints[j] > ints[j + 1]) {
                    temp = ints[j];
                    ints[j] = ints[j + 1];
                    ints[j + 1] = temp;
                }
            }
        }
        logger.info("输出排序后的");
        for (int i = 0; i < ints.length; i++) {
            logger.info(ints[i] + "");
        }
    }

    public static void main(String[] args) {
        bubbliing();
    }
}
